home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96a.txt
/
000178_icon-group-sender _Thu Aug 8 21:45:53 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1996-09-05
|
4KB
Received: by cheltenham.cs.arizona.edu; Mon, 12 Aug 1996 07:46:34 MST
Date: Thu, 8 Aug 96 21:45:53 CDT
From: yak@comm.mot.com (Yarko Tymciurak)
Message-Id: <9608090245.AA06361@platov8>
To: X041RS@tamvm1.tamu.edu, icon-group@cs.arizona.edu
Subject: Re: dos system call
Errors-To: icon-group-errors@cs.arizona.edu
Status: O
| Errors-To: icon-group-errors@cs.arizona.edu
| Date: Tue, 06 Aug 96 15:25:19 CDT
| From: Roger Sorrells <X041RS@tamvm1.tamu.edu>
| Subject: dos system call
| To: icon-group@cs.arizona.edu
| Errors-To: icon-group-errors@cs.arizona.edu
|
| when I include the lines
| system("set") #1
| system("set x=y") #2
| system("set") #3
| in a program, I get the same output from #3 as from #1,
| no additional X=y among the environment variables.
|
| How do I set DOS environment variables from within an Icon program?
| I am using MS-DOS 6.21 and Icon 8.10
|
(Now, for some totally deviant technical bable, from
old brain cells, loaded a long time ago. Memory may be corrupt
or out of date after a dozen years or so since last refresh...
...far more than you wanted to know...enjoy...)
Actually, every process (Unix and DOS) get's it's own copy of the
parent process environment (what good is setting the environment
of a parent process where there are hundreds of child processes,
for example?).
As a process, it makes sense that you only get to change what you
see, and what affects you or your children processes.
When you use "SET" in DOS, you are - in effect - using a built-in
shell command that sets that shell's own environment. Ergo,
system("set...") only sets the environment of the running process.
Under a system command, you can't even inspect with your
Icon process, since "system" is a call to a new shell- a child of
the calling Icon process. It get's a copy of you're Icon environment,
which explains your example (each "system" call is a new process, each
with its own copy of the Icon environment - which isn't changed
anywhere between system calls). Icon has a getenv() function, but
no corresponding setenv() as far as I recall, so you can't change
the environment you pass to children this way.
Now, since DOS is single tasking, and since it's process memory
allocation is a simple, singly linked list (last I checked ...),
it is possible (and unsupported) to change the "master" (that is,
boot-shell's) environment. With pointers, you can find the
memory allocation header to your process's environment, and
thread (really, search) your way through lower memory until you
find the master (which is different from child environment memory
allocation headers in that - if I remember - the pointer to the
next memory block is to lower instead of higher memory).
This is REALLY goofy stuff (and fun!). The only reason I know -
I put together a command that read a port and saved info on what
was on that port in an environment var once upon a midnight
dreary.... (Someone told me there was no way to do it, so I had
to). Since memory is allocated in some finite chunks (used to be
16 bytes), you have to be careful not to overwrite other memory.
The DOS environment is a contiguous byte string, and you can't ever
be sure if you'll have any memory to play with at the end of an
allocation chain. Therefor, you can only change existing
environment variables (or overwrite space used by existing ones),
and practically can't set them to anything longer than what
they are already set to. If that's useful (changing characters,
"a" to "b", for example)....
...it can be done (not any "simple" way I can see in Icon), but
you don't want to do it!
Older, and wiser (?),
Yarko.